﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Supplement_data
{
    internal class EntityConvertUtil
    {
        ///// <summary>
        ///// 将老小时报数据映射为新小时报数据
        ///// </summary>
        ///// <param name="list">老小时报数据列表</param>
        ///// <returns>新小时报数据列表</returns>
        //internal static List<NHourRpt> ConvertHourEntity(List<HourRpt> list)
        //{
        //    List<NHourRpt> nList = new List<NHourRpt>();
        //    if (list.Count == 0) { return nList; }
        //    // 遍历旧实体集合
        //    foreach (var it in list)
        //    {
        //        NHourRpt nIt = new NHourRpt
        //        {
        //            Slot_id = it.Slot_id.Trim(),
        //            Record_date = it.Record_date,
        //            Record_hour = it.Record_hour,
        //            Electric = (decimal)Math.Round(it.Electric, 1),
        //            Volt_set = (decimal)Math.Round(it.Volt_set / 1000, 3),
        //            Work_volt = (decimal)Math.Round(it.Volt_work, 3),
        //            Volt_avg = (decimal)Math.Round(it.Volt_avg, 3),
        //            Nb_interval_set = it.Nb_interval_set,
        //            Nb_total = (decimal)Math.Round(it.Nb_num, 1),
        //            Nb_times = it.Nb_times,
        //            Alumina_nb_total = 0,
        //            Alumina_nb_times = it.Small_nb_times + it.Manual_small_nb_times +
        //            (it.Big_nb_times + it.Manual_big_nb_times) * 2,
        //            Nb_owe_times = it.Nb_owe_times,
        //            Nb_over_times = it.Nb_over_times,
        //            Auto_small_nb_times = it.Small_nb_times,
        //            Auto_big_nb_times = it.Big_nb_times,
        //            Manual_small_nb_times = it.Manual_small_nb_times,
        //            Manual_big_nb_times = it.Manual_big_nb_times,
        //            Fluoride_salt_nb_total = (decimal)Math.Round(it.Fu_salt_value, 1),
        //            Fluoride_salt_nb_times = it.Fu_salt_times + it.Manual_fu_salt_times,
        //            Auto_fluoride_salt_nb_times = it.Fu_salt_times,
        //            Manual_fluoride_salt_nb_times = it.Manual_fu_salt_times,
        //            Exception_volt_avg = (decimal)Math.Round(it.Exception_volt_avg, 3),
        //            Exception_volt_duration = (decimal)Math.Round(it.Exception_volt_interval, 1),
        //            Avg_vibration = (decimal)Math.Round(it.Vibration_value, 3),
        //            Vibration_serious_duration = (decimal)Math.Round(it.Vibration_interval, 1),
        //            Avg_swing = (decimal)Math.Round(it.Swing_value, 3),
        //            Swing_serious_duration = (decimal)Math.Round(it.Swing_interval, 1),
        //            Sum_power_waste = (decimal)Math.Round(it.Pow_waste, 1),
        //            Exception_power_waste = (decimal)Math.Round(it.Exception_volt_avg * it.Electric * it.Exception_volt_interval / 60, 1),
        //            Out_al_time = "",
        //            Change_anode_time = "",
        //            Auto_anode_up_times = it.Auto_pole_up_times,
        //            Auto_anode_down_times = it.Auto_pole_down_times,
        //            Manual_anode_up_times = it.Manual_pole_up_times,
        //            Manual_anode_down_times = it.Manual_pole_dwon_times
        //        };
        //        if (it.Nb_times > 0)
        //        {
        //            var singleNum = it.Nb_num / it.Nb_times;
        //            nIt.Alumina_nb_total = (decimal)Math.Round(nIt.Alumina_nb_times * singleNum, 1);
        //        }
        //        List<string> outAlList = new List<string>();
        //        if (it.Out_al_first_time != null && it.Out_al_first_time.ToString() != "0001/1/1 0:00:00")
        //        {
        //            outAlList.Add(it.Out_al_first_time.ToString("HH:mm:ss"));
        //        }
        //        if (it.Out_al_second_time != null && it.Out_al_second_time.ToString() != "0001/1/1 0:00:00")
        //        {
        //            outAlList.Add(it.Out_al_second_time.ToString("HH:mm:ss"));
        //        }
        //        if (it.Out_al_third_time != null && it.Out_al_third_time.ToString() != "0001/1/1 0:00:00")
        //        {
        //            outAlList.Add(it.Out_al_third_time.ToString("HH:mm:ss"));
        //        }
        //        if (outAlList.Count > 0)
        //        {
        //            nIt.Out_al_time = string.Join(" | ", outAlList);
        //        }
        //        if (it.Chang_pole_time != null && it.Chang_pole_time.ToString() != "0001/1/1 0:00:00")
        //        {
        //            nIt.Change_anode_time = it.Chang_pole_time.ToString("HH:mm:ss");
        //        }
        //        nList.Add(nIt);
        //    }
        //    return nList;
        //}

        ///// <summary>
        ///// 将老班报数据映射为新班报数据
        ///// </summary>
        ///// <param name="list">老班报数据列表</param>
        ///// <returns>新班报数据列表</returns>
        //internal static List<NShiftRpt> ConvertShiftEntity(List<ShiftRpt> list)
        //{
        //    List<NShiftRpt> nList = new List<NShiftRpt>();
        //    if (list == null | list.Count == 0) { return nList; }
        //    foreach (var it in list)
        //    {
        //        NShiftRpt nIt = new NShiftRpt
        //        {
        //            Slot_id = it.Slot_id.Trim(),
        //            Record_date = it.Record_date,
        //            Shift_id = it.Shift_time_id,
        //            Status = it.Status,
        //            Electric = (decimal)Math.Round(it.Electric, 1),
        //            Volt_set = (decimal)Math.Round(it.Volt_set / 1000, 3),
        //            Work_volt = (decimal)Math.Round(it.Volt_work, 3),
        //            Volt_avg = (decimal)Math.Round(it.Volt_avg, 3),
        //            Nb_interval_set = it.Nb_interval_set,
        //            Nb_total = (decimal)Math.Round(it.Nb_num, 1),
        //            Nb_times = it.Nb_times,
        //            Alumina_nb_total = 0,
        //            Alumina_nb_times = it.Small_nb_times + it.Manual_small_nb_times +
        //            (it.Big_nb_times + it.Manual_big_nb_times) * 2,
        //            Nb_owe_times = it.Nb_own_times,
        //            Nb_over_times = it.Nb_over_times,
        //            Auto_small_nb_times = it.Small_nb_times,
        //            Auto_big_nb_times = it.Big_nb_times,
        //            Manual_small_nb_times = it.Manual_small_nb_times,
        //            Manual_big_nb_times = it.Manual_big_nb_times,
        //            Fluoride_salt_nb_total = (decimal)Math.Round(it.Fu_salt_value, 1),
        //            Fluoride_salt_nb_times = it.Fu_salt_times + it.Manual_fu_salt_times,
        //            Auto_fluoride_salt_nb_times = it.Fu_salt_times,
        //            Manual_fluoride_salt_nb_times = it.Manual_fu_salt_times,
        //            Exception_volt_avg = (decimal)Math.Round(it.Exception_volt_avg, 3),
        //            Exception_volt_duration = (decimal)Math.Round(it.Exception_volt_interval, 1),
        //            Avg_vibration = (decimal)Math.Round(it.Vibration_value, 3),
        //            Vibration_serious_duration = (decimal)Math.Round(it.Vibration_interval, 1),
        //            Avg_swing = (decimal)Math.Round(it.Swing_value, 3),
        //            Swing_serious_duration = (decimal)Math.Round(it.Swing_interval, 1),
        //            Sum_power_waste = (decimal)Math.Round(it.Pow_waste, 1),
        //            Exception_power_waste = (decimal)Math.Round(it.Exception_volt_avg * it.Electric * it.Exception_volt_interval / 60, 1),
        //            Out_al_time = "",
        //            Change_anode_time = "",
        //            Auto_anode_up_times = it.Auto_pole_up_times,
        //            Auto_anode_down_times = it.Auto_pole_down_times,
        //            Manual_anode_up_times = it.Manual_pole_up_times,
        //            Manual_anode_down_times = it.Manual_pole_dwon_times
        //        };
        //        if (it.Nb_times > 0)
        //        {
        //            var singleNum = it.Nb_num / it.Nb_times;
        //            nIt.Alumina_nb_total = (decimal)Math.Round(nIt.Alumina_nb_times * singleNum, 1);
        //        }
        //        List<string> outAlList = new List<string>();
        //        if (it.Out_al_first_time != null && it.Out_al_first_time.ToString() != "0001/1/1 0:00:00")
        //        {
        //            outAlList.Add(it.Out_al_first_time.ToString("HH:mm:ss"));
        //        }
        //        if (it.Out_al_second_time != null && it.Out_al_second_time.ToString() != "0001/1/1 0:00:00")
        //        {
        //            outAlList.Add(it.Out_al_second_time.ToString("HH:mm:ss"));
        //        }
        //        if (it.Out_al_third_time != null && it.Out_al_third_time.ToString() != "0001/1/1 0:00:00")
        //        {
        //            outAlList.Add(it.Out_al_third_time.ToString("HH:mm:ss"));
        //        }
        //        if (outAlList.Count > 0)
        //        {
        //            nIt.Out_al_time = string.Join(" | ", outAlList);
        //        }
        //        if (it.Chang_pole_time != null && it.Chang_pole_time.ToString() != "0001/1/1 0:00:00")
        //        {
        //            nIt.Change_anode_time = it.Chang_pole_time.ToString("HH:mm:ss");
        //        }
        //        nList.Add(nIt);
        //    }
        //    return nList;
        //}

        ///// <summary>
        ///// 将老日报数据映射为新日报数据
        ///// </summary>
        ///// <param name="list">老日报数据列表</param>
        ///// <returns>新班报数据列表</returns>
        ///// <exception cref="NotImplementedException"></exception>
        //internal static List<NDayRpt> ConvertDayEntity(List<DayRpt> list)
        //{
        //    List<NDayRpt> nList = new List<NDayRpt>();
        //    if (list == null | list.Count == 0)
        //    {
        //        return nList;
        //    }
        //    foreach (var it in list)
        //    {
        //        NDayRpt nIt = new NDayRpt
        //        {
        //            Slot_id = it.Slot_id.Trim(),
        //            Record_date = it.Record_date,
        //            Status = it.Status,
        //            Electric = (decimal)Math.Round(it.Electric, 1),
        //            Volt_set = (decimal)Math.Round(it.Volt_set / 1000, 3),
        //            Work_volt = (decimal)Math.Round(it.Volt_work, 3),
        //            Volt_avg = (decimal)Math.Round(it.Volt_avg, 3),
        //            Nb_interval_set = it.Nb_interval_set,
        //            Nb_total = (decimal)Math.Round(it.Nb_num, 1),
        //            Nb_times = it.Nb_times,
        //            Alumina_nb_total = 0,
        //            Alumina_nb_times = it.Small_nb_times + it.Manual_small_nb_times +
        //            (it.Big_nb_times + it.Manual_big_nb_times) * 2,
        //            Nb_owe_times = it.Nb_own_times,
        //            Nb_over_times = it.Nb_over_times,
        //            Auto_small_nb_times = it.Small_nb_times,
        //            Auto_big_nb_times = it.Big_nb_times,
        //            Manual_small_nb_times = it.Manual_small_nb_times,
        //            Manual_big_nb_times = it.Manual_big_nb_times,
        //            Fluoride_salt_nb_total = (decimal)Math.Round(it.Fu_salt_value, 1),
        //            Fluoride_salt_nb_times = it.Fu_salt_times + it.Manual_fu_salt_times,
        //            Auto_fluoride_salt_nb_times = it.Fu_salt_times,
        //            Manual_fluoride_salt_nb_times = it.Manual_fu_salt_times,
        //            Exception_volt_avg = (decimal)Math.Round(it.Exception_volt_avg, 3),
        //            Exception_volt_duration = (decimal)Math.Round(it.Exception_volt_interval, 1),
        //            Avg_vibration = (decimal)Math.Round(it.Vibration_value, 3),
        //            Vibration_serious_duration = (decimal)Math.Round(it.Vibration_interval, 1),
        //            Avg_swing = (decimal)Math.Round(it.Swing_value, 3),
        //            Swing_serious_duration = (decimal)Math.Round(it.Swing_interval, 1),
        //            Sum_power_waste = (decimal)Math.Round(it.Pow_waste, 1),
        //            Exception_power_waste = (decimal)Math.Round(it.Exception_volt_avg * it.Electric * it.Exception_volt_interval / 60, 1),
        //            Out_al_time = "",
        //            Change_anode_time = "",
        //            Auto_anode_up_times = it.Auto_pole_up_times,
        //            Auto_anode_down_times = it.Auto_pole_down_times,
        //            Manual_anode_up_times = it.Manual_pole_up_times,
        //            Manual_anode_down_times = it.Manual_pole_dwon_times
        //        };
        //        if (it.Nb_times > 0)
        //        {
        //            var singleNum = it.Nb_num / it.Nb_times;
        //            nIt.Alumina_nb_total = (decimal)Math.Round(nIt.Alumina_nb_times * singleNum, 1);
        //        }
        //        List<string> outAlList = new List<string>();
        //        if (it.Out_al_first_time != null && it.Out_al_first_time.ToString() != "0001/1/1 0:00:00")
        //        {
        //            outAlList.Add(it.Out_al_first_time.ToString("HH:mm:ss"));
        //        }
        //        if (it.Out_al_second_time != null && it.Out_al_second_time.ToString() != "0001/1/1 0:00:00")
        //        {
        //            outAlList.Add(it.Out_al_second_time.ToString("HH:mm:ss"));
        //        }
        //        if (it.Out_al_third_time != null && it.Out_al_third_time.ToString() != "0001/1/1 0:00:00")
        //        {
        //            outAlList.Add(it.Out_al_third_time.ToString("HH:mm:ss"));
        //        }
        //        if (outAlList.Count > 0)
        //        {
        //            nIt.Out_al_time = string.Join(" | ", outAlList);
        //        }
        //        if (it.Chang_pole_time != null && it.Chang_pole_time.ToString() != "0001/1/1 0:00:00")
        //        {
        //            nIt.Change_anode_time = it.Chang_pole_time.ToString("HH:mm:ss");
        //        }
        //        nList.Add(nIt);
        //    }
        //    return nList;
        //}

        /// <summary>
        /// 将老工艺数据映射为新工艺数据
        /// </summary>
        /// <param name="list">老工艺数据列表</param>
        /// <returns>新工艺数据列表</returns>
        //internal static List<NProcessData> ConvertProcessEntity(List<ProcessData> list)
        //{
        //    List<NProcessData> nList = new List<NProcessData>();
        //    if (list == null | list.Count == 0) { return nList; }
        //    foreach (var it in list)
        //    {
        //        NProcessData nIt = new NProcessData
        //        {
        //            Slot_id = it.Slot_id.Trim(),
        //            Record_date = it.Record_date,
        //            Al_temp = (decimal)Math.Round(it.Temp, 1),
        //            Base_al_level = (decimal)Math.Round(it.Base_al_level, 1),
        //            Al_level = (decimal)Math.Round(it.Al_level, 1),
        //            Electrolyte_level = (decimal)Math.Round(it.Electrolyte_level, 1),
        //            Slot_temp = (decimal)Math.Round(it.Slot_temp, 1),
        //            Cry_add = (decimal)Math.Round(it.Cry_add, 1),
        //            Cry_temp = (decimal)Math.Round(it.Cry_temp, 1),
        //            Press_drop = (decimal)Math.Round((it.Press_drop_aa + it.Press_drop_bb) / 2, 1),
        //            Insulation_thick = (decimal)Math.Round(it.Insulation_thick, 1),
        //            Polar_distance = (decimal)Math.Round(it.Polar_distance, 1),
        //            Anode_piece_id = "",
        //            Advice_out_al = (decimal)Math.Round(it.Advice_out_al, 1),
        //            Al_suction = (decimal)Math.Round(it.Total_al, 1),
        //            Ana_fe = (decimal)Math.Round(it.Ana_fe, 3),
        //            Ana_si = (decimal)Math.Round(it.Ana_si, 3),
        //            Ana_ca = (decimal)Math.Round(it.Ana_ca, 3),
        //            Ana_mg = (decimal)Math.Round(it.Ana_mg, 3),
        //            Al_quality = (decimal)Math.Round(it.Al_quality, 2),
        //            Al_grade = "",
        //            Molecular_ratio = (decimal)Math.Round(it.Molertio, 2),
        //            Ana_al2o3 = (decimal)Math.Round(it.Ana_al2_o3, 2),
        //            Ana_alf = (decimal)Math.Round(it.Ana_alf, 2),
        //            Ana_caf = (decimal)Math.Round(it.Ana_caf, 3),
        //            Ana_mgf = (decimal)Math.Round(it.Ana_maf, 3),
        //            Ana_lif = (decimal)Math.Round(it.Ana_lif, 3),
        //            Ana_kf = (decimal)Math.Round(it.Ana_kf, 3)
        //        };
        //        if (it.Pole_piece_id != 0)
        //        {
        //            nIt.Anode_piece_id = ((int)it.Pole_piece_id).ToString();
        //        }
        //        nList.Add(nIt);
        //    }
        //    return nList;
        //}

        ///// <summary>
        ///// 将老效应数据映射为新效应数据
        ///// </summary>
        ///// <param name="list">老效应数据列表</param>
        ///// <returns>新效应数据列表</returns>
        ///// <exception cref="NotImplementedException"></exception>
        //internal static List<NEffectData> ConvertEffectEntity(List<EffectData> list)
        //{
        //    List<NEffectData> nList = new List<NEffectData>();
        //    if (list.Count == 0) { return nList; }
        //    foreach (var it in list)
        //    {
        //        NEffectData nIt = new NEffectData
        //        {
        //            Slot_id = it.Slot_id,
        //            Record_date = it.Record_date,
        //            Effect_duration = it.Continue_time,
        //            Effect_volt_max = it.Volt_max,
        //            Effect_volt_avg = it.Volt_avg,
        //            Effect_power_waste = it.Power_waste,
        //            Effect_type = it.Continue_time > 50 ? 1 : 2
        //        };
        //        nList.Add(nIt);
        //    }
        //    return nList;
        //}

        ///// <summary>
        ///// 将老故障数据映射到新故障数据
        ///// </summary>
        ///// <param name="list"></param>
        ///// <returns></returns>
        ///// <exception cref="NotImplementedException"></exception>
        //internal static List<NFaultData> ConvertFaultEntity(List<FaultData> list)
        //{
        //    List<NFaultData> nList = new List<NFaultData>();
        //    if (list.Count == 0) { return nList; }
        //    foreach (var it in list)
        //    {
        //        NFaultData nIt = new NFaultData
        //        {
        //            Slot_id = it.Slot_id,
        //            Record_date = it.Record_date,
        //            Msg = it.Msg
        //        };
        //        nList.Add(nIt);
        //    }
        //    return nList;
        //}

        ///// <summary>
        ///// 将老人工操作数据映射为新人工操作数据
        ///// </summary>
        ///// <param name="list">老人工操作数据列表</param>
        ///// <returns>新人工操作数据列表</returns>
        ///// <exception cref="NotImplementedException"></exception>
        //internal static List<NOperateData> ConvertOperateEntity(List<OperateData> list)
        //{
        //    List<NOperateData> nList = new List<NOperateData>();
        //    if (list.Count == 0) { return nList; }
        //    foreach (var it in list)
        //    {
        //        NOperateData nIt = new NOperateData
        //        {
        //            Slot_id = it.Slot_id,
        //            Record_date = it.Operate_date,
        //            Msg = it.Operate_msg
        //        };
        //        nList.Add(nIt);
        //    }
        //    return nList;
        //}

        ///// <summary>
        ///// 将老参数修改记录映射为新参数修改记录
        ///// </summary>
        ///// <param name="list">老参数修改记录列表</param>
        ///// <returns>新参数修改记录列表</returns>
        ///// <exception cref="NotImplementedException"></exception>
        //internal static List<NParamChangeData> ConvertParamChangeEntity(List<ParamChangeData> list)
        //{
        //    List<NParamChangeData> nList = new List<NParamChangeData>();
        //    if (list.Count == 0) { return nList; }
        //    foreach (var it in list)
        //    {
        //        NParamChangeData nIt = new NParamChangeData
        //        {
        //            Slot_id = it.Slot_id,
        //            Record_date = it.Record_date,
        //            Change_type = it.Change_type,
        //            Origin_value = it.Origin_value.ToString(),
        //            Modify_value = it.Modify_value.ToString(),
        //            User_name = it.User_name,
        //            Ip_address = ""
        //        };
        //        nList.Add(nIt);
        //    }
        //    return nList;
        //}

        /// <summary>
        /// 将老历史曲线数据映射为新历史曲线数据
        /// </summary>
        /// <param name="list">老历史曲线数据列表</param>
        /// <returns>新历史曲线数据列表</returns>
        //internal static List<HistoryData> ConvertHistoryEntity(List<HistoryData> list)
        //{
        //    foreach (var it in list)
        //    {
        //        it.Date = DateTimeUtils.OldTimeToNewtime(it.Date);
        //    }
        //    List<HistoryData> nList = new List<HistoryData>();
        //    if (list == null && list.Count == 0) { return nList; }
        //    // 获取最后一条数据的日期，作为今天的开始时间
        //    DateTime todayStartTime = list[list.Count - 1].Date.Date;
        //    // 创建新的历史数据集合
        //    List<NHistoryData> nsList = new List<NHistoryData>();
        //    // 循环遍历数据，判断数据是否连续，如果不连续，需要补全数据
        //    for (int i = 0; i < list.Count; i++)
        //    {
        //        // 获取数据转换后的日期
        //        DateTime convertTime = DateTimeUtils.OldTimeToNewtime(list[i].Date);
        //        // 处理第一条数据
        //        if (i == 0)
        //        {
        //            // 判断日期时间是否大于等于实际第一条数据的日期时间，需要往前补数据
        //            if (convertTime >= todayStartTime.AddSeconds(5))
        //            {
        //                // 计算当前数据的日期与第一条数据的日期的差值
        //                var diff = (convertTime - todayStartTime.AddSeconds(5)).TotalSeconds;
        //                // 计算需要补的数据的数量
        //                int count = (int)diff / 10;
        //                if (count >= 0)
        //                {
        //                    // 循环补数据
        //                    for (int j = count; j > 0; j--)
        //                    {
        //                        var data = ConvertToNewHistory(list[i]);
        //                        data.Record_time = data.Record_time.AddSeconds(-10 * j);
        //                        if (data.Record_time >= todayStartTime.AddSeconds(5))
        //                        { nList.Add(data); }
        //                    }
        //                }
        //            }
        //        }
        //        // 处理中间数据
        //        else
        //        {
        //            // 判断当前数据的日期与前一条数据的日期的差值
        //            var diff = (convertTime - ConvertToNewHistory(list[i - 1]).Record_time).TotalSeconds;
        //            // 如果相差大于10秒，需要从上一个数据往后补数据
        //            int count = (int)diff / 10;
        //            if (count > 0)
        //            {
        //                // 循环补数据
        //                for (int j = 1; j <= count; j++)
        //                {
        //                    if (j == count)
        //                    {
        //                        // 自身当前数据
        //                        var currDdata = ConvertToNewHistory(list[i]);
        //                        if (currDdata.Record_time >= todayStartTime.AddSeconds(5))
        //                        {
        //                            nList.Add(currDdata);
        //                        }
        //                    }
        //                    else
        //                    {
        //                        var preData = ConvertToNewHistory(list[i - 1]);
        //                        preData.Record_time = preData.Record_time.AddSeconds(10 * j);
        //                        if (preData.Record_time >= todayStartTime.AddSeconds(5))
        //                        { nList.Add(preData); }
        //                    }
        //                }
        //            }
        //        }
        //        // 处理最后一条数据
        //        if (i == list.Count - 1)
        //        {
        //            // 最后一条数据与实际最后一条数据的时间差值
        //            var diff = (todayStartTime.AddDays(1).AddSeconds(-5) - convertTime).TotalSeconds;
        //            // 计算需要补的数据的数量
        //            int count = (int)diff / 10;
        //            if (count > 0)
        //            {
        //                // 循环补数据
        //                for (int j = 1; j <= count; j++)
        //                {
        //                    var data = ConvertToNewHistory(list[i]);
        //                    data.Record_time = data.Record_time.AddSeconds(10 * j);
        //                    nList.Add(data);
        //                }
        //            }
        //        }
        //    }
        //    nList = nList.GroupBy(it => it.Record_time).Select(it => it.First()).ToList();
        //    return nList;
        //}

        private static NHistoryData ConvertToNewHistory(HistoryData it)
        {
            return new NHistoryData
            {
                //Slot_id = it.Slot_id,
                //Record_time = DateTimeUtils.OldTimeToNewtime(it.Date),
                //Electric = Math.Round(it.Electric, 2),
                //Volt = Math.Round(it.Volt, 3),
                //Volt_set = (decimal)Math.Round((double)it.Volt_set / 1000.0, 3),
                //Max_control_volt = (decimal)Math.Round((double)it.Volt_upper_limit, 3),
                //Min_control_volt = (decimal)Math.Round((double)it.Volt_lower_limit, 3),
                //Resistance = Math.Round(it.Resistance, 3),
                //Filter_res = Math.Round(it.Filter_res, 3),
                //Smooth_res = Math.Round(it.Smooth_res, 3),
                //Vibration = it.Vibration,
                //Swing = it.Swing,
                //Acc_slope = (int)it.Accsloper,
                //Nb_interval_real = it.Real_nb_interval,
                //Nb_interval_set = it.Set_nb_interval,
                //Nb_mode = it.Nb_mode,
                //Nb_status = (short)it.Bank_state,
                //Fluoride_salt_nb_status = (short)it.Fu_salt,
                //Effect_status = (short)it.Reaction,
                //Effect_ago = it.Reaction_interval,
                //Control_status = 0,
                //Anode_move_status = (short)it.Pole_up_down,
                //Out_al_status = (short)it.Out_al,
                //Change_anode_status = (short)it.Change_pole,
                //Edge_process_status = (short)it.Side_process,
                //Raise_bus_status = (short)it.Bus_put_up,
                //Purely_manual_status = (short)it.Pure_man_operation
            };
        }

        private static HistoryData NewHistory(HistoryData it)
        {
            return new HistoryData
            {
                //Slot_id = it.Slot_id,
                //Record_time = DateTimeUtils.OldTimeToNewtime(it.Date),
                //Electric = Math.Round(it.Electric, 2),
                //Volt = Math.Round(it.Volt, 3),
                //Volt_set = Math.Round(it.Volt_set, 3),
                //Max_control_volt = (decimal)Math.Round(it.Volt_upper_limit, 3),
                //Min_control_volt = (decimal)Math.Round(it.Volt_lower_limit, 3),
                //Resistance = Math.Round(it.Resistance, 3),
                //Filter_res = Math.Round(it.Filter_res, 3),
                //Smooth_res = Math.Round(it.Smooth_res, 3),
                //Vibration = it.Vibration,
                //Swing = it.Swing,
                //Acc_slope = (int)it.Accsloper,
                //Nb_interval_real = it.Real_nb_interval,
                //Nb_interval_set = it.Set_nb_interval,
                //Nb_mode = it.Nb_mode,
                //Nb_status = (short)it.Bank_state,
                //Fluoride_salt_nb_status = (short)it.Fu_salt,
                //Effect_status = (short)it.Reaction,
                //Effect_ago = it.Reaction_interval,
                //Control_status = 0,
                //Anode_move_status = (short)it.Pole_up_down,
                //Out_al_status = (short)it.Out_al,
                //Change_anode_status = (short)it.Change_pole,
                //Edge_process_status = (short)it.Side_process,
                //Raise_bus_status = (short)it.Bus_put_up,
                //Purely_manual_status = (short)it.Pure_man_operation
            };
        }
    }
}